package org.shpitzick;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class UI extends javax.swing.JFrame
{
    randomName randomName = new randomName();
    String name = randomName.getName();
    
    public UI()
    {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        nameDisplayer = new javax.swing.JLabel();
        welcomer = new javax.swing.JLabel();
        anotherRandomName = new javax.swing.JButton();
        copyleft = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Random Names Generator");
        setBackground(new java.awt.Color(255, 255, 255));

        nameDisplayer.setBackground(new java.awt.Color(255, 255, 255));
        nameDisplayer.setText("I randomly generated the name " + name);

        welcomer.setBackground(new java.awt.Color(255, 255, 255));
        welcomer.setText("Welcome to my unuseful random names generator!");

        anotherRandomName.setText("Not bad! Do it again!");
        anotherRandomName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                anotherRandomNameActionPerformed(evt);
            }
        });

        copyleft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/shpitzick/resources/Copyleft.png"))); // NOI18N
        copyleft.setText("Copyleft Shpitzick");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(welcomer))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(80, 80, 80)
                                .addComponent(anotherRandomName)))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(copyleft)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(nameDisplayer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(welcomer)
                .addGap(18, 18, 18)
                .addComponent(nameDisplayer)
                .addGap(18, 18, 18)
                .addComponent(anotherRandomName)
                .addGap(18, 18, 18)
                .addComponent(copyleft)
                .addGap(10, 10, 10))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void anotherRandomNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_anotherRandomNameActionPerformed
        name = randomName.getName();
        nameDisplayer.setText("I randomly generated the name " + name);
    }//GEN-LAST:event_anotherRandomNameActionPerformed

    public static void main(String args[])
    {
        try {
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(UI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(UI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(UI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(UI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
            java.awt.EventQueue.invokeLater(new Runnable()
            {
                public void run()
                {
                    new UI().setVisible(true);
                }
            });      
            
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(UI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(UI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(UI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(UI.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton anotherRandomName;
    private javax.swing.JLabel copyleft;
    private javax.swing.JLabel nameDisplayer;
    private javax.swing.JLabel welcomer;
    // End of variables declaration//GEN-END:variables
}
